import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 课程消课记录信息 */
export interface CourseCancel {
          id: number; // 主键ID
          studentId?: number; // 学生ID
          commodityId?: number; // 课程商品ID
          classesId?: number; // 班级ID
          cancelTime?: string | Dayjs; // 消课时间
          teachingTime?: number; // 消课时长
          restDuration?: number; // 剩余时长
  }

// 课程消课记录 API
export const CourseCancelApi = {
  // 查询课程消课记录分页
  getCourseCancelPage: async (params: any) => {
    return await request.get({ url: `/train/course-cancel/page`, params })
  },

  // 查询课程消课记录详情
  getCourseCancel: async (id: number) => {
    return await request.get({ url: `/train/course-cancel/get?id=` + id })
  },

  // 新增课程消课记录
  createCourseCancel: async (data: CourseCancel) => {
    return await request.post({ url: `/train/course-cancel/create`, data })
  },

  // 修改课程消课记录
  updateCourseCancel: async (data: CourseCancel) => {
    return await request.put({ url: `/train/course-cancel/update`, data })
  },

  // 删除课程消课记录
  deleteCourseCancel: async (id: number) => {
    return await request.delete({ url: `/train/course-cancel/delete?id=` + id })
  },

  /** 批量删除课程消课记录 */
  deleteCourseCancelList: async (ids: number[]) => {
    return await request.delete({ url: `/train/course-cancel/delete-list?ids=${ids.join(',')}` })
  },

  // 导出课程消课记录 Excel
  exportCourseCancel: async (params) => {
    return await request.download({ url: `/train/course-cancel/export-excel`, params })
  },
}